package com.ssd.controller.consumer;


import com.ssd.entity.PointsRecord;
import com.ssd.entity.PointsRecordTotal;
import com.ssd.entity.dto.response.PointsRecordPageInfoResDTO;
import com.ssd.service.IPointsRecordTotalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 积分总表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-21
 */
@RestController("consumerPointsRecordTotalController")
@RequestMapping("/consumer/points-record-total")
@Api(tags = "用户端-积分总表控制器")
public class PointsRecordTotalController {
    @Resource
    private IPointsRecordTotalService pointsRecordTotalService;

    /**
     * 根据用户id获取我的总积分
     * @return
     */
    @GetMapping("/getPointsRecordTotal")
    @ApiOperation(value = "获取我的总积分")
    public Integer getPointsRecordTotal(){
        return pointsRecordTotalService.getPointsRecordTotal();
    }

    /**
     * 查看我的积分明细
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lastId", value = "上一次查询最后一张积分记录id"
                    , required = false, dataTypeClass = Long.class),
            @ApiImplicitParam(name = "status", value = "积分方式：1-收入，2-使用"
                    , required = true, dataTypeClass = Long.class)
    })
    @GetMapping("/list")
    @ApiOperation(value = "查看我的积分明细")
    public List<PointsRecordPageInfoResDTO> queryPointsRecordForPage(
            @RequestParam(value = "lastId", required = false)Long lastId,
            @RequestParam(value = "status" ,required = true) Integer status){
        return pointsRecordTotalService.queryPointsRecordForPage(lastId,status);
    }

}
